// Variable
// (c) jimon game studio

#ifndef JEH_JEVARIABLE
#define JEH_JEVARIABLE

#include "jeStl.h"

namespace je
{
	namespace core
	{
		enum SystemVariableType
		{
			SVT_BYTE,
			SVT_FLOAT32,
			SVT_FLOAT64,
			SVT_INT32,
			SVT_INT64,
			SVT_STRING,
			SVT_POINTER
		};

		//! Variables
		class jeVariable
		{
		public:
			//! Variable Name
			jeStringc Name;

			//! Variable Data
			void * Data;

			//! Variable Type
			SystemVariableType Type;

			//! Delete Variable Data
			void DeleteData()
			{
				if(Data)
					switch(Type)
					{
					case SVT_BYTE:
						JEDELETE(static_cast<c8*>(Data))
						break;
					case SVT_INT32:
					case SVT_FLOAT32:
						JEDELETE(static_cast<f32*>(Data))
						break;
					case SVT_INT64:
					case SVT_FLOAT64:
						JEDELETE(static_cast<f64*>(Data))
						break;
					case SVT_STRING:
						JEDELETE(static_cast<jeStringd*>(Data))
						break;
					case SVT_POINTER:
						break;
					}
			}

			//! Constructor
			jeVariable()
				:Data(NULL),Type(SVT_BYTE)
			{
				Name = "";
			}

			//! Destructor
			~jeVariable()
			{
				DeleteData();
			}

			//! Get Size
			s32 GetSize()
			{
				switch(Type)
				{
				case SVT_BYTE:
					return 1;
				case SVT_FLOAT32:
				case SVT_INT32:
					return 4;
				case SVT_FLOAT64:
				case SVT_INT64:
					return 8;
				case SVT_STRING:
					return static_cast<jeStringd*>(Data)->GetSize();
				case SVT_POINTER:
					return sizeof(void*);
				default:
					return -1;
				}
			}
		};
	}
}

#endif
